<#include "/base/common/head.html"/>



<div id="cc" class="easyui-layout" data-options="fit:true,border:false" style="">
    	<div class="easyui-panel" title="菜单列表" data-options="fit:true,border:false,header:'#tt'">
	       	<ul id="menuTree"></ul>
    	</div>
    	
    	<div id="tt" style="height:25px" style="background-color:#fc0;">
	        <span> &nbsp;菜单列表 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span>
	        <a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-floppy-disk" plain="true" onclick="saveAuth()" style="color: #398DEE" >保存</a>
	    </div>
	   
</div>

<style type="text/css">

.l-btn-icon, .menu-icon{ color: #398DEE; }

</style>

<script>

var roleId = "${roleId!}"; 

//保存权限
function saveAuth()
{
	if(!roleId) {
		showWarnMsg("请选择角色！");
		return;
	}
	
	//获得选中菜单
	var menuIds = "";
	$.each($('#menuTree').tree('getChecked'), function(i, item) {
		menuIds += "," + item.id;
	});
	menuIds = menuIds.replace(",", ""); //替换掉第一个逗号
	
	var param = {roleId: roleId, menuIds: menuIds};
	
	$.post("editAuth", param, function(data) {
		
		if("01" == data.code){//成功
			showMsg(data.msg); //显示消息
		}else if("04" == data.code){//失败
			showErrorMsg(data.msg); //显示错误消息
		}
		
	});
	 
}

$.post(basePath+"/base/resource/findAllForselect?roleId=" + roleId, function(data){
	
	$("#menuTree").tree({
		data: data,
		checkbox:true,
		onBeforeSelect: treeBeforeSelect
	});
});

//在点选一个节点时，打开或折叠该节点
function treeBeforeSelect(node) {
    if(node.children && node.children.length > 0) {
        if(node.state == "open") {
            $(this).tree("collapse", node.target);
        }else {
            $(this).tree("expand", node.target);
        }
        return false;
    } 
}


</script>
<#include "/base/common/foot.html"/>